package com.fafa.thread;

import static java.lang.Thread.sleep;

public class CupNum {
    public static void main(String[] args) throws InterruptedException {

        Thread t1 = new Thread(new Hellowrld());
        //线程守护
        t1.setDaemon(true);
        t1.start();
        sleep(10);
    }

}

//接口写线程
class Hellowrld implements Runnable {
    private final Runtime runtime = Runtime.getRuntime();
    private Boolean running = true; //设置何时停止

    @Override
    public void run() {
        while (running) {
            System.out.println("hello world");
            System.out.println("当前CPU核心数" + runtime.availableProcessors());
        }
    }

    public void setRunning(Boolean running) {
        this.running = running;
    }
}